/*
 *  Copyright 2019-2020 Zheng Jie
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.fzhucc.modules.security.rest;

import com.fzhucc.annotation.rest.AnonymousGetMapping;
import com.fzhucc.modules.security.service.AuthenticationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 * @author yyg
 */

@RestController
@RequiredArgsConstructor
@RequestMapping("/api/cross")
@Api(tags = "系统：跳转管理")
public class CrossController {

    private final AuthenticationService authenticationService;

    @CrossOrigin(origins = "*", maxAge = 3600)
    @GetMapping("/loginTemporary")
    @ApiOperation("登录至sci")
    public void loginTemporary(@RequestParam String type, HttpServletResponse resp) {
        authenticationService.loginTemporary(type, resp);
    }

    @AnonymousGetMapping("/sciloginkc")
    @ApiOperation("sci登录至科创")
    public void sciloginkc(@RequestParam String phone, HttpServletResponse resp, HttpServletRequest request) {
        authenticationService.sciloginkc(phone, resp, request);
    }

}
